class GroupSummary < Plugin
	
	def initialize()
		@probe_count = Array.new(Gene.group_count, 0)
		@probe_total = Array.new(Gene.group_count, 0)
	end

	def push_gene(gene)
		if( gene.probe_groups )
			gene.probe_groups.each_with_index do |pg, i|
				if(pg)
					@probe_count[i] += pg.probes.size
					@probe_total[i] += pg.probes.inject(0) { |sum, p| sum += p.probe_value } 
				end
			end
		end
	end

	def finalize
		@probe_avg = []
		@probe_total.each_with_index do |pt, i| 
			@probe_avg << ((@probe_count[i] == 0) ?
								0 : pt / @probe_count[i])
		end

	end

	def to_s
		s = 	"----PROBE GROUP SUMMARY----\n"
		s +=	"Dist:\t" + @probe_count.join("\t") + "\n"
		s += 	"Avg:\t" + @probe_avg.join("\t") + "\n"
	end


end
